Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(database): add DragonflyDB operator and cluster resources #2808

Merged
merged 1 commit into from
Apr 10, 2024

Conversation

tyriis
Copy link
Owner

@tyriis tyriis commented Apr 10, 2024

No description provided.

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@tyriis-automation
Copy link
Contributor

--- kubernetes/talos-flux/apps Kustomization: flux-system/apps-sync Kustomization: flux-system/apps-dragonfly-operator

+++ kubernetes/talos-flux/apps Kustomization: flux-system/apps-sync Kustomization: flux-system/apps-dragonfly-operator

@@ -0,0 +1,36 @@

+---
+apiVersion: kustomize.toolkit.fluxcd.io/v1
+kind: Kustomization
+metadata:
+  labels:
+    kustomize.toolkit.fluxcd.io/name: apps-sync
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: apps-dragonfly-operator
+  namespace: flux-system
+spec:
+  commonMetadata:
+    labels:
+      app.kubernetes.io/component: dragonfly
+      app.kubernetes.io/instance: dragonfly-operator
+      app.kubernetes.io/name: dragonfly-operator
+  decryption:
+    provider: sops
+    secretRef:
+      name: sops-age
+  interval: 30m
+  path: ./kubernetes/talos-flux/apps/database/dragonfly/operator
+  postBuild:
+    substituteFrom:
+    - kind: ConfigMap
+      name: cluster-settings
+    - kind: Secret
+      name: cluster-secrets
+  prune: true
+  retryInterval: 1m
+  sourceRef:
+    kind: GitRepository
+    name: home-ops
+  targetNamespace: database
+  timeout: 5m
+  wait: true
+
--- kubernetes/talos-flux/apps Kustomization: flux-system/apps-sync Kustomization: flux-system/apps-dragonfly-cluster

+++ kubernetes/talos-flux/apps Kustomization: flux-system/apps-sync Kustomization: flux-system/apps-dragonfly-cluster

@@ -0,0 +1,38 @@

+---
+apiVersion: kustomize.toolkit.fluxcd.io/v1
+kind: Kustomization
+metadata:
+  labels:
+    kustomize.toolkit.fluxcd.io/name: apps-sync
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: apps-dragonfly-cluster
+  namespace: flux-system
+spec:
+  commonMetadata:
+    labels:
+      app.kubernetes.io/component: dragonfly
+      app.kubernetes.io/instance: dragonfly-cluster
+      app.kubernetes.io/name: dragonfly-cluster
+  decryption:
+    provider: sops
+    secretRef:
+      name: sops-age
+  dependsOn:
+  - name: apps-dragonfly-operator
+  interval: 30m
+  path: ./kubernetes/talos-flux/apps/database/dragonfly/cluster
+  postBuild:
+    substituteFrom:
+    - kind: ConfigMap
+      name: cluster-settings
+    - kind: Secret
+      name: cluster-secrets
+  prune: true
+  retryInterval: 1m
+  sourceRef:
+    kind: GitRepository
+    name: home-ops
+  targetNamespace: database
+  timeout: 5m
+  wait: true
+
--- kubernetes/talos-flux/apps/database/dragonfly/cluster Kustomization: flux-system/apps-dragonfly-cluster Dragonfly: database/dragonfly

+++ kubernetes/talos-flux/apps/database/dragonfly/cluster Kustomization: flux-system/apps-dragonfly-cluster Dragonfly: database/dragonfly

@@ -0,0 +1,32 @@

+---
+apiVersion: dragonflydb.io/v1alpha1
+kind: Dragonfly
+metadata:
+  labels:
+    app.kubernetes.io/component: dragonfly
+    app.kubernetes.io/instance: dragonfly-cluster
+    app.kubernetes.io/name: dragonfly-cluster
+    kustomize.toolkit.fluxcd.io/name: apps-dragonfly-cluster
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: dragonfly
+  namespace: database
+spec:
+  args:
+  - --maxmemory=$(MAX_MEMORY)Mi
+  - --proactor_threads=2
+  - --cluster_mode=emulated
+  - --lock_on_hashtags
+  env:
+  - name: MAX_MEMORY
+    valueFrom:
+      resourceFieldRef:
+        divisor: 1Mi
+        resource: limits.memory
+  image: ghcr.io/dragonflydb/dragonfly:v1.16.1
+  replicas: 4
+  resources:
+    limits:
+      memory: 512Mi
+    requests:
+      cpu: 100m
+
--- kubernetes/talos-flux/apps/database/dragonfly/cluster Kustomization: flux-system/apps-dragonfly-cluster PodMonitor: database/dragonfly

+++ kubernetes/talos-flux/apps/database/dragonfly/cluster Kustomization: flux-system/apps-dragonfly-cluster PodMonitor: database/dragonfly

@@ -0,0 +1,21 @@

+---
+apiVersion: monitoring.coreos.com/v1
+kind: PodMonitor
+metadata:
+  labels:
+    app.kubernetes.io/component: dragonfly
+    app.kubernetes.io/instance: dragonfly-cluster
+    app.kubernetes.io/name: dragonfly-cluster
+    kustomize.toolkit.fluxcd.io/name: apps-dragonfly-cluster
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: dragonfly
+  namespace: database
+spec:
+  podMetricsEndpoints:
+  - port: admin
+  podTargetLabels:
+  - app
+  selector:
+    matchLabels:
+      app: dragonfly
+
--- kubernetes/talos-flux/apps/database/dragonfly/operator Kustomization: flux-system/apps-dragonfly-operator HelmRelease: database/dragonfly-operator

+++ kubernetes/talos-flux/apps/database/dragonfly/operator Kustomization: flux-system/apps-dragonfly-operator HelmRelease: database/dragonfly-operator

@@ -0,0 +1,112 @@

+---
+apiVersion: helm.toolkit.fluxcd.io/v2beta2
+kind: HelmRelease
+metadata:
+  labels:
+    app.kubernetes.io/component: dragonfly
+    app.kubernetes.io/instance: dragonfly-operator
+    app.kubernetes.io/name: dragonfly-operator
+    kustomize.toolkit.fluxcd.io/name: apps-dragonfly-operator
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: dragonfly-operator
+  namespace: database
+spec:
+  chart:
+    spec:
+      chart: app-template
+      sourceRef:
+        kind: HelmRepository
+        name: bjw-s-charts
+        namespace: flux-system
+      version: 3.1.0
+  install:
+    remediation:
+      retries: 3
+  interval: 30m
+  upgrade:
+    cleanupOnFail: true
+    remediation:
+      retries: 3
+      strategy: rollback
+  values:
+    controllers:
+      dragonfly-operator:
+        containers:
+          app:
+            args:
+            - --health-probe-bind-address=:8081
+            - --metrics-bind-address=:8080
+            command:
+            - /manager
+            image:
+              repository: ghcr.io/dragonflydb/operator
+              tag: v1.1.2@sha256:f0d76725950095ac65b36252e0042d339d1db9b181b1d068f4b6686ea93055e4
+            probes:
+              liveness:
+                custom: true
+                enabled: true
+                spec:
+                  failureThreshold: 3
+                  httpGet:
+                    path: /healthz
+                    port: 8081
+                  initialDelaySeconds: 15
+                  periodSeconds: 20
+                  timeoutSeconds: 1
+              readiness:
+                custom: true
+                enabled: true
+                spec:
+                  failureThreshold: 3
+                  httpGet:
+                    path: /readyz
+                    port: 8081
+                  initialDelaySeconds: 5
+                  periodSeconds: 10
+                  timeoutSeconds: 1
+            resources:
+              limits:
+                memory: 128Mi
+              requests:
+                cpu: 10m
+            securityContext:
+              allowPrivilegeEscalation: false
+              capabilities:
+                drop:
+                - ALL
+              readOnlyRootFilesystem: true
+        pod:
+          securityContext:
+            runAsGroup: 65534
+            runAsNonRoot: true
+            runAsUser: 65534
+          topologySpreadConstraints:
+          - labelSelector:
+              matchLabels:
+                app.kubernetes.io/name: dragonfly-operator
+            maxSkew: 1
+            topologyKey: kubernetes.io/hostname
+            whenUnsatisfiable: DoNotSchedule
+        replicas: 1
+        strategy: RollingUpdate
+    service:
+      app:
+        controller: dragonfly-operator
+        ports:
+          http:
+            port: 8081
+          metrics:
+            port: 8080
+    serviceAccount:
+      create: true
+      name: dragonfly-operator
+    serviceMonitor:
+      app:
+        endpoints:
+        - interval: 1m
+          path: /metrics
+          port: metrics
+          scheme: http
+          scrapeTimeout: 10s
+        serviceName: dragonfly-operator
+
--- kubernetes/talos-flux/apps/database/dragonfly/operator Kustomization: flux-system/apps-dragonfly-operator ClusterRole: flux-system/dragonfly-operator

+++ kubernetes/talos-flux/apps/database/dragonfly/operator Kustomization: flux-system/apps-dragonfly-operator ClusterRole: flux-system/dragonfly-operator

@@ -0,0 +1,83 @@

+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: ClusterRole
+metadata:
+  labels:
+    app.kubernetes.io/component: dragonfly
+    app.kubernetes.io/instance: dragonfly-operator
+    app.kubernetes.io/name: dragonfly-operator
+    kustomize.toolkit.fluxcd.io/name: apps-dragonfly-operator
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: dragonfly-operator
+rules:
+- apiGroups:
+  - coordination.k8s.io
+  resources:
+  - leases
+  verbs:
+  - get
+  - list
+  - watch
+  - create
+  - update
+  - patch
+  - delete
+- apiGroups:
+  - ''
+  resources:
+  - events
+  verbs:
+  - create
+  - patch
+- apiGroups:
+  - ''
+  resources:
+  - pods
+  - services
+  verbs:
+  - create
+  - delete
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - apps
+  resources:
+  - statefulsets
+  verbs:
+  - create
+  - delete
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - dragonflydb.io
+  resources:
+  - dragonflies
+  verbs:
+  - create
+  - delete
+  - get
+  - list
+  - patch
+  - update
+  - watch
+- apiGroups:
+  - dragonflydb.io
+  resources:
+  - dragonflies/finalizers
+  verbs:
+  - update
+- apiGroups:
+  - dragonflydb.io
+  resources:
+  - dragonflies/status
+  verbs:
+  - get
+  - patch
+  - update
+
--- kubernetes/talos-flux/apps/database/dragonfly/operator Kustomization: flux-system/apps-dragonfly-operator ClusterRoleBinding: flux-system/dragonfly-operator

+++ kubernetes/talos-flux/apps/database/dragonfly/operator Kustomization: flux-system/apps-dragonfly-operator ClusterRoleBinding: flux-system/dragonfly-operator

@@ -0,0 +1,20 @@

+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: ClusterRoleBinding
+metadata:
+  labels:
+    app.kubernetes.io/component: dragonfly
+    app.kubernetes.io/instance: dragonfly-operator
+    app.kubernetes.io/name: dragonfly-operator
+    kustomize.toolkit.fluxcd.io/name: apps-dragonfly-operator
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: dragonfly-operator
+roleRef:
+  apiGroup: rbac.authorization.k8s.io
+  kind: ClusterRole
+  name: dragonfly-operator
+subjects:
+- kind: ServiceAccount
+  name: dragonfly-operator
+  namespace: database
+

@tyriis-automation
Copy link
Contributor

--- HelmRelease: database/dragonfly-operator ServiceAccount: database/dragonfly-operator

+++ HelmRelease: database/dragonfly-operator ServiceAccount: database/dragonfly-operator

@@ -0,0 +1,12 @@

+---
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+  name: dragonfly-operator
+  labels:
+    app.kubernetes.io/instance: dragonfly-operator
+    app.kubernetes.io/managed-by: Helm
+    app.kubernetes.io/name: dragonfly-operator
+secrets:
+- name: dragonfly-operator-sa-token
+
--- HelmRelease: database/dragonfly-operator Service: database/dragonfly-operator

+++ HelmRelease: database/dragonfly-operator Service: database/dragonfly-operator

@@ -0,0 +1,26 @@

+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: dragonfly-operator
+  labels:
+    app.kubernetes.io/instance: dragonfly-operator
+    app.kubernetes.io/managed-by: Helm
+    app.kubernetes.io/name: dragonfly-operator
+    app.kubernetes.io/service: dragonfly-operator
+spec:
+  type: ClusterIP
+  ports:
+  - port: 8081
+    targetPort: 8081
+    protocol: TCP
+    name: http
+  - port: 8080
+    targetPort: 8080
+    protocol: TCP
+    name: metrics
+  selector:
+    app.kubernetes.io/component: dragonfly-operator
+    app.kubernetes.io/instance: dragonfly-operator
+    app.kubernetes.io/name: dragonfly-operator
+
--- HelmRelease: database/dragonfly-operator Deployment: database/dragonfly-operator

+++ HelmRelease: database/dragonfly-operator Deployment: database/dragonfly-operator

@@ -0,0 +1,83 @@

+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: dragonfly-operator
+  labels:
+    app.kubernetes.io/component: dragonfly-operator
+    app.kubernetes.io/instance: dragonfly-operator
+    app.kubernetes.io/managed-by: Helm
+    app.kubernetes.io/name: dragonfly-operator
+spec:
+  revisionHistoryLimit: 3
+  replicas: 1
+  strategy:
+    type: RollingUpdate
+  selector:
+    matchLabels:
+      app.kubernetes.io/component: dragonfly-operator
+      app.kubernetes.io/name: dragonfly-operator
+      app.kubernetes.io/instance: dragonfly-operator
+  template:
+    metadata:
+      annotations:
+        checksum/secrets: 4141e6981f3b767e75a4e744858b9ff414dba5d0ef6afd761f7700061fb6e32e
+      labels:
+        app.kubernetes.io/component: dragonfly-operator
+        app.kubernetes.io/instance: dragonfly-operator
+        app.kubernetes.io/name: dragonfly-operator
+    spec:
+      enableServiceLinks: false
+      serviceAccountName: dragonfly-operator
+      automountServiceAccountToken: true
+      securityContext:
+        runAsGroup: 65534
+        runAsNonRoot: true
+        runAsUser: 65534
+      hostIPC: false
+      hostNetwork: false
+      hostPID: false
+      dnsPolicy: ClusterFirst
+      topologySpreadConstraints:
+      - labelSelector:
+          matchLabels:
+            app.kubernetes.io/name: dragonfly-operator
+        maxSkew: 1
+        topologyKey: kubernetes.io/hostname
+        whenUnsatisfiable: DoNotSchedule
+      containers:
+      - args:
+        - --health-probe-bind-address=:8081
+        - --metrics-bind-address=:8080
+        command:
+        - /manager
+        image: ghcr.io/dragonflydb/operator:v1.1.2@sha256:f0d76725950095ac65b36252e0042d339d1db9b181b1d068f4b6686ea93055e4
+        livenessProbe:
+          failureThreshold: 3
+          httpGet:
+            path: /healthz
+            port: 8081
+          initialDelaySeconds: 15
+          periodSeconds: 20
+          timeoutSeconds: 1
+        name: app
+        readinessProbe:
+          failureThreshold: 3
+          httpGet:
+            path: /readyz
+            port: 8081
+          initialDelaySeconds: 5
+          periodSeconds: 10
+          timeoutSeconds: 1
+        resources:
+          limits:
+            memory: 128Mi
+          requests:
+            cpu: 10m
+        securityContext:
+          allowPrivilegeEscalation: false
+          capabilities:
+            drop:
+            - ALL
+          readOnlyRootFilesystem: true
+
--- HelmRelease: database/dragonfly-operator ServiceMonitor: database/dragonfly-operator

+++ HelmRelease: database/dragonfly-operator ServiceMonitor: database/dragonfly-operator

@@ -0,0 +1,26 @@

+---
+apiVersion: monitoring.coreos.com/v1
+kind: ServiceMonitor
+metadata:
+  name: dragonfly-operator
+  labels:
+    app.kubernetes.io/instance: dragonfly-operator
+    app.kubernetes.io/managed-by: Helm
+    app.kubernetes.io/name: dragonfly-operator
+spec:
+  jobLabel: dragonfly-operator
+  namespaceSelector:
+    matchNames:
+    - database
+  selector:
+    matchLabels:
+      app.kubernetes.io/service: dragonfly-operator
+      app.kubernetes.io/name: dragonfly-operator
+      app.kubernetes.io/instance: dragonfly-operator
+  endpoints:
+  - interval: 1m
+    path: /metrics
+    port: metrics
+    scheme: http
+    scrapeTimeout: 10s
+

@tyriis-automation
Copy link
Contributor

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ EDITORCONFIG editorconfig-checker 8 0 0.03s
✅ REPOSITORY gitleaks yes no 2.29s
✅ YAML prettier 8 0 0.68s
✅ YAML yamllint 8 0 0.38s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

Copy link
Collaborator

@jazzlyn jazzlyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@tyriis tyriis merged commit c39923c into main Apr 10, 2024
15 checks passed
@tyriis tyriis deleted the feature/dragonfly branch April 10, 2024 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants